package priv.wangy.micro.common.constant;

import lombok.Getter;
import priv.wangy.micro.common.po.http.rspn.BaseListRspn;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author zhangjq
 * @since 2024-05-20
 */
@Getter
public enum StudentConstant {
    ON_REGISTER_ON_SCHOOL("100", "在籍在校", "STATUS", StudentStatus.OnRegisterOnSchool.class),
    ON_REGISTER_OFF_SCHOOL("200", "在籍不在校", "STATUS", StudentStatus.OnRegisterOffSchool.class),
    OFF_REGISTER_ON_SCHOOL("300", "不在籍在校", "STATUS", StudentStatus.OffRegisterOnSchool.class),
    OFF_REGISTER_OFF_SCHOOL("400", "不在籍不在校", "STATUS", StudentStatus.OffRegisterOffSchool.class),

    // 毕业方向
    JY("100", "就业", "GRADUATION_DIRECTION", GraduationDirection.StuJy.class),
    SX("200", "升学", "GRADUATION_DIRECTION", GraduationDirection.StuSx.class),
    WJY("300", "未就业", "GRADUATION_DIRECTION", GraduationDirection.StuWjy.class);
    /**
     * 学生状态集合
     */
    public static final BaseListRspn.Field STUDENT_STATUS_COL_FIELD = new BaseListRspn.Field("STUDENT_STATUS_COL", Arrays.asList(
            new BaseListRspn.Field.Property(ON_REGISTER_ON_SCHOOL.getValue(), ON_REGISTER_ON_SCHOOL.getDisplay()),
            new BaseListRspn.Field.Property(ON_REGISTER_OFF_SCHOOL.getValue(), ON_REGISTER_OFF_SCHOOL.getDisplay()),
            new BaseListRspn.Field.Property(OFF_REGISTER_ON_SCHOOL.getValue(), OFF_REGISTER_ON_SCHOOL.getDisplay()),
            new BaseListRspn.Field.Property(OFF_REGISTER_OFF_SCHOOL.getValue(), OFF_REGISTER_OFF_SCHOOL.getDisplay()))
    );

    public static final BaseListRspn.Field BY_FIELD = new BaseListRspn.Field("GRADUATION_DIRECTION", Arrays.asList(
            GraduationDirection.StuJy.QHT.getProperty(),
            GraduationDirection.StuJy.YWB.getProperty(),
            GraduationDirection.StuJy.ZZCY.getProperty(),
            GraduationDirection.StuJy.NHJY.getProperty(),
            GraduationDirection.StuSx.PTGK.getProperty(),
            GraduationDirection.StuSx.ZJGK.getProperty(),
            GraduationDirection.StuSx.CGCJ.getProperty(),
            GraduationDirection.StuSx.GTPY.getProperty(),
            GraduationDirection.StuSx.WNYGZ.getProperty(),
            GraduationDirection.StuWjy.DJY.getProperty(),
            GraduationDirection.StuWjy.BJY.getProperty(),
            GraduationDirection.StuWjy.QT.getProperty()
    ));

    /**
     * 未就业
     */
    public static final BaseListRspn.Field WJY_FIELD = new BaseListRspn.Field("GRADUATION_DIRECTION", Arrays.asList(
            GraduationDirection.StuWjy.DJY.getProperty(),
            GraduationDirection.StuWjy.BJY.getProperty(),
            GraduationDirection.StuWjy.QT.getProperty()
    ));

    public static final BaseListRspn.Field STUDENT_STATUS_FIELD = new BaseListRspn.Field("STUDENT_STATUS", Arrays.asList(
            StudentStatus.OnRegisterOnSchool.ZD.getProperty(),
            StudentStatus.OnRegisterOnSchool.FX.getProperty(),
            StudentStatus.OnRegisterOffSchool.BLRXZG.getProperty(),
            StudentStatus.OnRegisterOffSchool.XX.getProperty(),
            StudentStatus.OnRegisterOffSchool.GPCX.getProperty(),
            StudentStatus.OnRegisterOffSchool.XLBM.getProperty(),
            StudentStatus.OffRegisterOnSchool.JD.getProperty(),
            StudentStatus.OffRegisterOffSchool.TX.getProperty(),
            StudentStatus.OffRegisterOffSchool.LS.getProperty(),
            StudentStatus.OffRegisterOffSchool.BY.getProperty(),
            StudentStatus.OffRegisterOffSchool.JY.getProperty(),
            StudentStatus.OffRegisterOffSchool.YY.getProperty(),
            StudentStatus.OffRegisterOffSchool.ZX.getProperty(),
            StudentStatus.OffRegisterOffSchool.SW.getProperty(),
            StudentStatus.OffRegisterOffSchool.KC.getProperty(),
            StudentStatus.OffRegisterOffSchool.QT.getProperty()
    ));
    private final String value;
    private final String display;
    private final String field;
    private final IStudentConstant[] studentConstants;

    StudentConstant(String value, String display, String field) {
        this.value = value;
        this.display = display;
        this.field = field;
        this.studentConstants = null;
    }

    StudentConstant(String value, String display, String field, Class<? extends IStudentConstant> studentConstants) {
        this.value = value;
        this.display = display;
        this.field = field;
        this.studentConstants = studentConstants.getEnumConstants();
    }

    public static List<String> getOnRegisterStatus() {
        List<String> status = new ArrayList<>();
        status.addAll(Arrays.stream(StudentStatus.OnRegisterOnSchool.values()).map(IStudentConstant::getProperty)
                .map(BaseListRspn.Field.Property::getStrValue).toList());
        status.addAll(Arrays.stream(StudentStatus.OnRegisterOnSchool.values()).map(IStudentConstant::getProperty)
                .map(BaseListRspn.Field.Property::getStrValue).toList());
        return status;
    }

    public interface IStudentConstant {
        BaseListRspn.Field.Property getProperty();
    }

    /**
     * 学生状态
     */
    public interface StudentStatus {

        enum OnRegisterOnSchool implements IStudentConstant {
            ZD {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("101", "在读");
                }
            },
            FX {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("102", "复学");
                }
            }
        }

        enum OnRegisterOffSchool implements IStudentConstant {
            BLRXZG {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("201", "保留入学资格");
                }
            },
            XX {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("202", "休学");
                }
            },
            GPCX {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("203", "公派出国");
                }
            },
            XLBM {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("204", "下落不明");
                }
            },
        }

        enum OffRegisterOnSchool implements IStudentConstant {
            JD {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("301", "借读");
                }
            }
        }

        enum OffRegisterOffSchool implements IStudentConstant {
            TX {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("401", "退学");
                }
            },
            LS {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("402", "流失");
                }
            },
            BY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("403", "毕业");
                }
            },
            JY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("404", "结业");
                }
            },
            YY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("405", "肄业");
                }
            },
            ZX {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("406", "转学（转出）");
                }
            },
            SW {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("407", "死亡");
                }
            },
            KC {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("408", "开除");
                }
            },
            QT {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("409", "其他");
                }
            }
        }
    }

    public interface GraduationDirection {
        enum StuJy implements IStudentConstant {
            QHT {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("101", "就业-签订合同或就业协议就业");
                }

            }, YWB {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("102", "就业-应征义务兵");
                }

            }, ZZCY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("103", "就业-自主创业");
                }

            }, NHJY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("104", "就业-灵活就业");
                }

            },
        }

        enum StuSx implements IStudentConstant {
            PTGK {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("201", "升学-普通高考升学");
                }

            }, ZJGK {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("202", "升学-职教高考升学");
                }

            }, CGCJ {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("203", "升学-出国、出境升学");
                }

            }, GTPY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("204", "升学-贯通培养升学");
                }

            },
            WNYGZ {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("205", "升学-五年一贯制升学");
                }

            },
        }

        enum StuWjy implements IStudentConstant {
            DJY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("301", "未就业-待就业");
                }

            }, BJY {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("302", "未就业-不就业拟升学");
                }

            }, QT {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("303", "未就业-其他暂不就业");
                }

            },
        }
    }


}